#include "crypto/algorithms/symmetric/SM4.h"
#include "crypto/algorithms/symmetric/Rijndael.h"
#include "crypto/algorithms/digest/SHA3.h"
#include "crypto/keys/FAQSecretKey.h"
#include "crypto/FAQCipher.h"
#include "util/Util.h"
#include "lang/System.h"
#include "util/ByteUtil.h"
#include "io/FileInputStream.h"
#include "util/DT.h"
using namespace yzrilyzr_crypto;
using namespace yzrilyzr_array;
using namespace yzrilyzr_util;
using namespace yzrilyzr_lang;
using namespace yzrilyzr_io;
int main(){
	/*FAQSecretKey key1(ByteArray({(int8_t)6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9}));
	ByteArray iv({(int8_t)6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9});
	FAQCipher cipher;
	cipher.setIV(iv);
	cipher.setTagLength(16);
	cipher.init("AES/GCM/NoPadding",FAQCipher::ENCRYPT_MODE,key1);
	ByteArray content({6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9, 6, 9});
	auto & cip=cipher.doFinal(content);
	System::out.print("Key: ");
	System::out.println(ByteUtil::byte2Hex(key1.getEncoded()));
	System::out.println(Util::b64(key1.getEncoded()));
	System::out.print("IV: ");
	System::out.println(ByteUtil::byte2Hex(iv));
	System::out.println(Util::b64(iv));
	System::out.print("Enc: ");
	System::out.println(ByteUtil::byte2Hex(cip));
	System::out.println(Util::b64(cip));
	System::out.println(cip);
	cipher.setIV(iv);
	cipher.setTagLength(16);
	cipher.init("AES/GCM/NoPadding", FAQCipher::DECRYPT_MODE, key1);
	auto & pip=cipher.doFinal(cip);
	System::out.print("Dec: ");
	System::out.println(ByteUtil::byte2Hex(pip));
	System::out.println(Util::b64(pip));
	System::out.println(pip);
	System::out.println(cipher);*/
	SHA3_256 dig;
	ByteArray buf(1024);
	int i;
	FileInputStream is("D:\\Projects\\Java\\FAQ\\FAQServerFileStore\\Server\\DB\\FAQServerFileStore\\main_ext\\37\\37901eddb16831ee3f888975e98d1357101b1553d264b0fb0ce09b9dfc457e2d");
	System::out.println("Start");
	DT dt;
	dt.getAndSetDeltaTime();
	while((i=is.read(buf)) != -1){
		dig.update(buf, 0, i);
	}
	ByteArray digb=dig.doFinal();
	System::out.println(dt.getAndSetDeltaTime());
	System::out.println(ByteUtil::byte2Hex(digb));
}